package com.zx._05_代理.JDKProxy;

import java.lang.reflect.Proxy;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class Main {

    public static void main(String[] args) {

        // 增强的代理类
        ProxyHandler proxy = new ProxyHandler(RealImplement.class);

        // 动态代理类的classLoader
        ClassLoader classLoader = Main.class.getClassLoader();

        // 需要代理类的接口
        Class[] interfaces = {InterfaceA.class};

        InterfaceA ia = (InterfaceA) Proxy.newProxyInstance(classLoader, interfaces, proxy);
        ia.exec();
        // ia.class=class com.sun.proxy.$Proxy0, ia.toString=com.zx._05_代理.JDKProxy.RealImplement@1442d7b5
        log.info("ia.class={}, ia.toString={}", ia.getClass(), ia.toString());
    }
}	
